import java.util.Arrays;


public class Solution1 {
    public void rotate(int[] nums, int k) {
        int length = nums.length;
        int[] arr = new int[length];

    // 遍历原始数组 nums 中的每个元素，将其放置到新数组 arr 的正确位置
        for(int i = 0; i < length; i++){
            arr[(i+k)%length] = nums[i];
        }
        for(int j = 0; j < length; j++){
            nums[j] = arr[j];
        }
    }

    public static void main(String[] args) {
        int[] num = {1, 2, 3, 4, 5, 6, 7};
        Solution1 solution1 = new Solution1();
        solution1.rotate(num, 3);
        System.out.println(Arrays.toString(num));
    }
}
